<?php

namespace Biz\model\activity;

use Doraemon\pockets\datebase\BaseDbModel;


class ActivityAwardDelivery extends BaseDbModel implements ActivityBasicInterface
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_brand_activity';

    const _DATABASE_ = 'brand_activity';

    const _TABLE_NAME = 'activity_award_delivery';

//    const ACTIVITY_CREATE_WIKI_LIST = 1; // 2022年双11清单活动-兴趣公寓
//    const ACTIVITY_SPOTLIGHT = 2; // 新品聚光灯

    const ADDRESS_SEPARATOR = ' | ';//地区码和详细地址分隔符;

    public static function addData($id = 0, $activity_id = self::ACTIVITY_CREATE_WIKI_LIST, $uid = 0, $award = '', $name = '', $encrypt_phone_id = '', $delivery_address = '', $created_at = 0)
    {
        if (empty($created_at)) $created_at = date('Y-m-d H:i:s');
        if ($id > 0) $updated_at = date('Y-m-d H:i:s');
        $data = compact('activity_id', 'uid', 'award', 'name', 'encrypt_phone_id', 'delivery_address', 'created_at');
        return $id > 0 ? self::update($data + ['updated_at' => $updated_at], ['id' => $id])->rowCount() : self::insert($data)->rowcount();
    }

    public static function hasData($activity_id = self::ACTIVITY_CREATE_WIKI_LIST, $uid = 0, $award = '')
    {
        return self::count(compact('activity_id', 'uid', 'award'));
    }
}